public class Test {

//        public MySingleList.ListNode getIntersectionNode(MySingleList.ListNode headA, MySingleList.ListNode headB) {
//            MySingleList.ListNode pl=headA;
//            MySingleList.ListNode ps=headB;
//            int lenA=0; //链表A的长度
//            int lenB=0; //链表B的长度
//            while(pl!=null){
//                pl=pl.next;
//                lenA++;
//            }
//            while(ps!=null){
//                ps=ps.next;
//                lenB++;
//            }
//            pl=headA;
//            ps=headB;
//            int len =lenA-lenB;
//            if(len<0){
//                pl=headB;
//                ps=headA;
//                len=lenB-lenA;
//            }
//            while(len!=0){
//                pl=pl.next;
//                len--;
//            }
//            while(pl!=ps){
//                pl=pl.next;
//                ps=ps.next;
//            }
//            return pl;
//        }
public static void main(String[] args) {
    MySingleList mySingleList=new MySingleList();
    mySingleList.addLast(15);
    mySingleList.addLast(12);
    mySingleList.addLast(23);
    mySingleList.addLast(28);
    mySingleList.addLast(36);
    mySingleList.addLast(13);
    mySingleList.createLoop();
   boolean flg=mySingleList.hasCycle(mySingleList.head);
    System.out.println(flg);
}

    public static void main6(String[] args) {
        MySingleList mySingleList1=new MySingleList();
        mySingleList1.addLast(15);
        mySingleList1.addLast(25);
        mySingleList1.addLast(35);
        mySingleList1.addLast(56);
        MySingleList mySingleList2=new MySingleList();
        mySingleList2.addLast(13);
        mySingleList2.addLast(18);
        mySingleList2.addLast(54);
         cut(mySingleList1.head,mySingleList2.head);
         mySingleList1.display();
    }
    private static void cut(MySingleList.ListNode headA, MySingleList.ListNode headB){
      headA.next.next=headB.next;
    }
    public static void main5(String[] args) {
        MySingleList mySingleList=new MySingleList();
        mySingleList.addLast(15);
        mySingleList.addLast(12);
        mySingleList.addLast(23);
        mySingleList.addLast(28);
        mySingleList.addLast(36);
        mySingleList.addLast(13);
        MySingleList.ListNode ret =mySingleList.partition(mySingleList.head,16);
        mySingleList.display(ret);
    }
    public static void main4(String[] args) {
        MySingleList mySingleList=new MySingleList();
        mySingleList.addLast(11);
        mySingleList.addLast(12);
        mySingleList.addLast(13);
        mySingleList.addLast(12);
        mySingleList.addLast(11);
        boolean ret=mySingleList.chkPalindrome();
        System.out.println(ret);
    }
    public static void main3(String[] args) {
        MySingleList mySingleList1=new MySingleList();
        mySingleList1.addLast(15);
        mySingleList1.addLast(25);
        mySingleList1.addLast(35);
        mySingleList1.addLast(56);
        MySingleList mySingleList2=new MySingleList();
        mySingleList2.addLast(13);
        mySingleList2.addLast(18);
        mySingleList2.addLast(54);
        MySingleList.ListNode newHead=mySingleList1.MergeTwoLinkedLists(mySingleList1.head,mySingleList2.head);
        mySingleList1.display(newHead);
    }
    public static void main2(String[] args) {
        MySingleList mySingleList=new MySingleList();
        mySingleList.addLast(12);
        mySingleList.addLast(15);
        mySingleList.addLast(24);
        mySingleList.addLast(42);
        mySingleList.addLast(28);
        int ret =mySingleList.kthToLast(3);
        System.out.println(ret);
        System.out.println("===========");
        //第一种方法进行测验
       // mySingleList.reverseList();
       // mySingleList.display();
        //第二种方法进行测验
       //MySingleList.ListNode ret=mySingleList.reverseList();
       //mySingleList.display(ret);
      // MySingleList.ListNode ret=mySingleList.middleNode();
        //System.out.println(ret.val);

    }
    public static void main1(String[] args) {
        MySingleList mySingleList=new MySingleList();
        mySingleList.createdList();
        mySingleList.display();
        System.out.println("求size:");
        System.out.println(mySingleList.size());
        System.out.println(mySingleList.contains(31));
        mySingleList.addFirst(85);
        mySingleList.display();
        mySingleList.addLast(53);
        mySingleList.display();
        mySingleList.addIndex(3,45);
        mySingleList.display();
        mySingleList.remove(85);
        mySingleList.display();
        mySingleList.removeAllKey(11);
        System.out.println("=======================");
        mySingleList.display();
        mySingleList.clear();

    }
}
